package com.opener.web.acl.service;

import com.opener.web.acl.model.SysFunction;
import com.opener.web.acl.model.UserRole;

import java.util.List;

/**
 *
 * @author baboy
 * @date 01/12/2016
 */
public interface AclService {

    public List<SysFunction> getAllFunctions();

    /**
     *
     * @param uri 匹配到的用户路由
     * @return
     */
    public SysFunction getFunction(String uri);
    public List<SysFunction> getFunctions(String uri);


    public UserRole getRole(String key);
    public UserRole getRole(Integer id);

    public int getSearchRolesCount(String name);
    public List<UserRole> searchRoles(String name, int offset, int pageSize);

    public boolean createRole(UserRole role);
    public boolean updateRole(UserRole role);
    public boolean updateRoleStatus(UserRole role);
    public boolean removeRole(int rid);
    public boolean updateRoleFunctions(int roleId, List<Integer> functionIds) ;
    public List<SysFunction> getRoleFunctions(int rid);

    public List<UserRole> getUserRoles(Long Long);
    public List<UserRole> getUserActiveRoles(Long uid);
    public boolean removeUserRoles(Long uid, List<Integer> roles);
    public boolean removeUserRoles(Long uid);
    public boolean addUserRoles(Long uid, List<UserRole> roles);
    public boolean isAdmin(UserRole role);

    /**
     * @param roles 用户的角色
     * @param uri 匹配到的用户路由
     * @return
     */
    public boolean hasRouteRights(List<UserRole> roles, String uri);

    public boolean isRoleActive(UserRole role);
    /**
     * @param roles 用户的角色
     * @param uri 匹配到的用户路由
     * @return
     */
    public List<UserRole> getRouteRoles(List<UserRole> roles,String uri);
    public List<SysFunction> getUserFunctions(Long uid);
    public List<SysFunction> getUserMenus(Long uid);
}
